package com.haoshuang.zhouzhoubang.ui.adapter


import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayoutManager
import com.google.android.flexbox.JustifyContent
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemMemberBinding
import com.haoshuang.zhouzhoubang.model.bean.SfBean
import com.haoshuang.zhouzhoubang.ui.page.order.assignment.ServiceLabelAdapter
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.load
import com.mufeng.libs.utils.view.visibleOrGone


/**
 * 订单模块中的订单列表适配器
 * */
class MegerAdapter(data: MutableList<SfBean>) :
    BaseBindingQuickAdapter<SfBean, ItemMemberBinding>(data){

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: SfBean?) {

        val binding = ItemMemberBinding.bind(holder.itemView)
        val flexboxLayoutManager1 = FlexboxLayoutManager(context)
        flexboxLayoutManager1.flexDirection = FlexDirection.ROW
        flexboxLayoutManager1.flexWrap = FlexWrap.WRAP   //按正常方向换行
        flexboxLayoutManager1.justifyContent = JustifyContent.FLEX_START //交叉轴的起点对齐。
        binding.apply {
            tvName.text = item?.nickname
            roundedImageView3.load(item?.avatar)

            when(0){
                0 -> {  // 隐藏状态
                    tvStateBusy.visibleOrGone(false)
                    tvStateLeisure.visibleOrGone(false)
                }
                1 -> {  // 显示状态
                    tvStateBusy.visibleOrGone(true)
                    tvStateLeisure.visibleOrGone(true)
                }
            }

            val mrvSerciceAdapter = ServiceLabelAdapter(item?.cate_name?: mutableListOf<String>())
            recyclerView.layoutManager = flexboxLayoutManager1	// 给recycleview设置布局管理者
            recyclerView.adapter = mrvSerciceAdapter
        }


    }

}